<include file="Public:head" />
<script src="__PUBLIC__/js/jquery/validate.js"></script>
<script type="text/javascript">
    $(function(){
        var mtype = "{$Think.get.mtype}";
        if(mtype>0){
            toTaskObject("textarea[name=content]");
        }
        $("#form").validate({
            errorPlacement: function(error, element){
                var error_td = element.parent('div');
                error_td.find('label.error').hide();
                error_td.append(error);
            },
            submitHandler:function(form){
                addMessages(mtype);
            },
            rules: {
                content:{
                required : true
            },
                code : {
                    required : true,
                    remote   : {
                        url : "{:U('Ajax/checkCode')}",
                        type: 'post',
                        data:{
                            code : function(){
                                return $('#code').val();
                            }
                        }
                    }
                }
            },
            messages: {
            content:{
                required : '留言内容不能为空'
            },
                code : {
                    required : '请输入验证码',
                    remote	 : '验证码有误'
                }
            }
        });
        $("#getcode_gg").click(function(){
            $(this).attr("src",'__PUBLIC__/js/group/code_gg.php?' + Math.random());
        });
    });
    function addMessages(mtype){
        var word = "成功提交留言";
        if(mtype>0){
            word = "成功提交催单";
        }
        var content = $("textarea[name=content]").val();
        var sid = "{$Think.get.id}";
        $.post("{:U('Ajax/addMessages')}",{
            content:content,
            sid:sid,
            mtype:mtype
        },function(data){
            $("textarea[name=content]").val('');
            var url = "__APP__/Area/messages/id/"+sid+".html";
         //   goUrl(url);
        })
    }
    function reply(id){
        toTaskObject("textarea[name=content]");
        $("textarea[name=content]").val("#"+id+"# ")
        $("textarea[name=content]").focus();
    }
   
</script>
<script>
    $(function(){
        checkMobileCart('{$is_mobile}');
    })
    </script>
<div id="wrap">
    <!--end of header-->
    <div id="container" class="clearfix">
        <div id="attentionInfo" class="clearfix">
            <div class="attention br8 rest">
                <p id="shopState"></p>
            </div>
        </div>
        <div id="school">
            {$type=1|getAreaName}
            <a href="__APP__/?type=clean">[切换位置]</a> <span>/</span> 
            <em id="shop" data-url="{:U('Area/detail',array('id'=>$id))}">{$detail.name}</em>
        </div>
        <div id="left" class="shadow s_menu">

                <div id="s_tab">
                    <a href="{:U('Area/detail',array('id'=>$id))}">看菜单</a>
                    <a href="{:U('Area/comments',array('id'=>$id))}">累积评价</a>
                    <a href="{:U('Area/messages',array('id'=>$id))}" class="active">给餐厅留言</a>
                </div>
                <div id="tab_comment">

                   
                    <foreach name="lists" item="row">
                    <div class="sm_list">
                        <p>{$row.content}</p>
                        <p>
                            <span class="sm_nick">
                                <if condition="$row.uid gt 0">{$row.uid|is_shop_admin=###}<else/>游客 {$row.uid2}</if></span><span class="sm_time">
                                {$row.addtime|tranTime=###}</span><a href="javascript:;" onclick="reply('{$row.id}')" class="sm_reply">回复</a></p>

                        
                        <foreach name="row['sub']" item="row2">
                        <div class="reply_info">
                            <p>{$row2.content}</p>
                            <p>
                                <span class="sm_nick"><if condition="$row2.uid gt 0">{$row2.uid|is_shop_admin=###}<else/>游客 {$row2.uid2}</if></span>
                                <span class="sm_time">{$row2.addtime|tranTime=###}</span>
                            </p>
                        </div>
                            </foreach>
                    </div>
                        </foreach>
                    <div class="page">{$page}</div>
                    <div class="make_msg">
                        <form id="form" method="POST" > 
                            <div style="margin:20px 0 0">
                                <label style="width:50px;">留言：</label>
                                <textarea  name="content" autocomplete="off">{$messages}</textarea>
                            </div>
                            <div class="chk_code" style="margin:20px 0 0">
                                <label style="width:50px;">验证码：</label>
                                <input type="text" class="input login_input_1" name="code"  id="code"  tabindex="3" autocomplete="off" />
                                <img src="__PUBLIC__/js/group/code_gg.php" id="getcode_gg" title="看不清，点击换一张" align="absmiddle">

                            </div>
                            <div class="btn" style="margin-top: 10px;">
                                <input type="submit" value="提交" id="btnSendClick" />
                            </div>
                        </form>
                    </div>

                </div>

            </div>
        <!--end of left-->
        <include file="Public:right" />
        <div class="clear"></div>
    </div>
</div>
<include file="Public:foot" />